<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateComentariosTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{

		Schema::create ( "comentarios", function ($table) {
			$table->increments ( 'id' );
			$table->longText ( 'contenido' );
			$table->integer ( 'user_id' )->unsigned();
			$table->foreign ( 'user_id' )->references ( 'id' )->on( 'users' )->onDelete('cascade');
		
			$table->timestamps ();
		} );
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		
		Schema::table('comentarios', function($table)
		{
			$table->dropForeign('comentarios_user_id_foreign');
		});
		
		Schema::dropIfExists( "comentarios");
	}

}
